package com.java.awt;

import java.awt.*;
import java.awt.event.*;

public class ListenerClient {

	private Frame frame;
	private Button bn;
	private TextField label;

	public void go(){
		frame =  new Frame("Border Layout");
		frame.addWindowListener(new WindowAdapter() {
			@Override
			public void windowOpened(WindowEvent e) {
				System.out.println("-------");
			}
		});
		label = new TextField(30) ;
		bn = new Button("B2");
		bn.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent e) {
				System.out.println("an xia");
			}
		});
		bn.addMouseMotionListener(new MouseMotionAdapter() {
			@Override
			public void mouseMoved(MouseEvent e) {
				label.setText(e.getX() + " : " + e.getY());
			}
		});
		frame.add(label,BorderLayout.NORTH);
		frame.add(bn);
		frame.setSize(200,200);//设置窗口大小
		frame.setVisible(true);//设置窗口可见
	}

	public static void main(String[] args) {
		ListenerClient gui = new ListenerClient();
		gui.go();
	}
}
